package com.ms.oschina.fragment;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ms.oschina.R;
import com.ms.oschina.base.BaseFragment;
import com.ms.oschina.bean.Event;
import com.ms.oschina.bean.Post;
import com.ms.oschina.bean.PostDetail;
import com.ms.oschina.util.UiUtils;

public class EventDetailTitleFragment extends BaseFragment {
	private TextView tvEventdetailTitle;
	private TextView tvEventdetailStartTime;
	private TextView tvEventdetailEndTime;
	private LinearLayout rlEventLocation;
	private TextView tvEventdetailSpot;
	private Button btEventdetailAttend;
	private Button btEventdetailApply;
	private TextView tvEventTip;

	OnClickListener listener;

	public EventDetailTitleFragment(OnClickListener listener) {
		this.listener = listener;
	}

	@Override
	public int getLayoutId() {
		return R.layout.fragment_eventdetail_title;
	}

	@Override
	public void initView(View view) {
		findViews(view);
	}

	/**
	 * Handle button click events<br />
	 * <br />
	 * Auto-created by Android Layout Finder
	 * (http://www.buzzingandroid.com/tools/android-layout-finder)
	 */
	private void findViews(View view) {
		tvEventdetailTitle = (TextView) view
				.findViewById(R.id.tv_eventdetail_title);
		tvEventdetailStartTime = (TextView) view
				.findViewById(R.id.tv_eventdetail_start_time);
		tvEventdetailEndTime = (TextView) view
				.findViewById(R.id.tv_eventdetail_end_time);
		rlEventLocation = (LinearLayout) view
				.findViewById(R.id.rl_event_location);
		tvEventdetailSpot = (TextView) view
				.findViewById(R.id.tv_eventdetail_spot);
		btEventdetailAttend = (Button) view
				.findViewById(R.id.bt_eventdetail_attend);
		btEventdetailApply = (Button) view
				.findViewById(R.id.bt_eventdetail_apply);
		tvEventTip = (TextView) view.findViewById(R.id.tv_event_tip);
	}
	
	@Override
	protected void initData() {
		btEventdetailAttend.setOnClickListener(listener);
		btEventdetailApply.setOnClickListener(listener);
		rlEventLocation.setOnClickListener(listener);
	}

	public void setTitle(PostDetail activitiesDetail) {
		Post post = activitiesDetail.getPost();
		Event event = post.getEvent();

		tvEventdetailTitle.setText(post.getTitle());
		tvEventdetailStartTime.setText(event.getStartTime());
		tvEventdetailEndTime.setText(event.getEndTime());
		tvEventdetailSpot.setText(event.getSpot());
	}

}
